//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.activiti.engine.impl.persistence.entity.data.impl;

import java.util.HashMap;
import java.util.List;
import org.activiti.engine.impl.DeadLetterJobQueryImpl;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.persistence.CachedEntityMatcher;
import org.activiti.engine.impl.persistence.entity.DeadLetterJobEntity;
import org.activiti.engine.impl.persistence.entity.DeadLetterJobEntityImpl;
import org.activiti.engine.impl.persistence.entity.data.AbstractDataManager;
import org.activiti.engine.impl.persistence.entity.data.DeadLetterJobDataManager;
import org.activiti.engine.impl.persistence.entity.data.impl.cachematcher.DeadLetterJobsByExecutionIdMatcher;
import org.activiti.engine.runtime.Job;

public class MybatisDeadLetterJobDataManager extends AbstractDataManager<DeadLetterJobEntity> implements DeadLetterJobDataManager {
  protected CachedEntityMatcher<DeadLetterJobEntity> deadLetterByExecutionIdMatcher = new DeadLetterJobsByExecutionIdMatcher();

  public MybatisDeadLetterJobDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) {
    super(processEngineConfiguration);
  }

  public Class<? extends DeadLetterJobEntity> getManagedEntityClass() {
    return DeadLetterJobEntityImpl.class;
  }

  public DeadLetterJobEntity create() {
    return new DeadLetterJobEntityImpl();
  }

  public void delete(DeadLetterJobEntity entity) {
    this.getDbSqlSession().delete(entity);
  }

  public List<Job> findJobsByQueryCriteria(DeadLetterJobQueryImpl jobQuery, Page page) {
    String query = "selectDeadLetterJobByQueryCriteria";
    return this.getDbSqlSession().selectList(query, jobQuery, page);
  }

  public long findJobCountByQueryCriteria(DeadLetterJobQueryImpl jobQuery) {
    return (Long)this.getDbSqlSession().selectOne("selectDeadLetterJobCountByQueryCriteria", jobQuery);
  }

  public List<DeadLetterJobEntity> findJobsByExecutionId(String executionId) {
    return this.getList("selectDeadLetterJobsByExecutionId", executionId, this.deadLetterByExecutionIdMatcher, true);
  }

  public void updateJobTenantIdForDeployment(String deploymentId, String newTenantId) {
    HashMap<String, Object> params = new HashMap();
    params.put("deploymentId", deploymentId);
    params.put("tenantId", newTenantId);
    this.getDbSqlSession().update("updateDeadLetterJobTenantIdForDeployment", params);
  }
}
